<?php
namespace Home\Controller;
use Think\Controller;
class LoginController extends Controller {

    public function login(){

        $verify = new \Think\Verify();
        if($verify->check(I('verify'))==false){
            $this->error("验证码错误");
        }
        $user=M('user');
        $username=$_POST['username'];
        $pwd= md5($_POST['password']);
//        var_dump($username);
//        var_dump($pwd);
//        exit();
        if($user->where("`username`='$username' AND `password`='$pwd'")->find()){
            //判断为真，表名登录成功
            session('username',$username);
            //跳转到Index控制器
            redirect(U('/Home/News/index/'),0,'跳转中...');
        }else{
//            echo $user->getLastSql();
//            exit();
            $this->error("用户名或密码错误");
        }


}


}